{include file="public/header" /}

<style>
    body {
        background: #FFF;
    }
</style>

<div class="page">
    <a href="javascript:history.go(-1)" class="btn" title="返回上一步">返回上一步</a>
    <table class="ds-default-table order">
        <tbody>

            <tr>
                <th>{$Think.lang.order_info}</th>
            </tr>
            <tr>
                <td colspan="2">
                    <ul>
                        <li><strong>{$Think.lang.ds_order_sn}:</strong>{$order_info.order_sn}</li>
                        <li><strong>{$Think.lang.order_state}:</strong>{$order_state[$order_info.order_state]}</li>
                        <li><strong>订单类型:</strong>{$order_type[$order_info.order_type]}</li>
                        <li><strong>订单预约时间:</strong>{$order_info.appointment_time}</li>
                        <li><strong>订单创建时间:</strong>{$order_info.add_time|date="Y-m-d H:i:s",###}</li>
                        <li><strong>订单备注:</strong>{$order_info.remarks}</li>
                    </ul>
                </td>
            </tr>

            <tr>
                <th>买家信息</th>
            </tr>
            <tr>
                <td colspan="2">
                    <ul>
                        <li><strong>买家账号:</strong>{$order_info.member_name}</li>
                        <li><strong>运营商:</strong>{$order_info.invite_store_name}</li>
                    </ul>
                </td>
            </tr>

            {notempty name="order_info.address"}
            <tr>
                <th>客户信息</th>
            </tr>
            <tr>
                <td>
                    <ul>
                        <li><strong>客户姓名{$Think.lang.ds_colon}</strong>{$order_info.address.address_realname}</li>
                        <li><strong>客户电话:</strong>{$order_info.appoint_phone}</li>
                        <li><strong>客户地址{$Think.lang.ds_colon}</strong>{$order_info.appoint_address}&nbsp;{$order_info.appoint_detail_address}&nbsp;
                        </li>
                    </ul>
                </td>
            </tr>
            {/notempty}

            <tr>
                <th>
                    <div>服务设备列表</div>
                    <!-- <?php if ($order_info['is_bring_goods'] == 1) {?>
                        <a style="width: 98px; height: 37px;line-height: 37px;background-color: #419dfd;margin-left: 98px;margin-top: -21px;" href="javascript:dsLayerOpen('{:url('Service/generate_commodity',['order_id'=>$order_id])}','','1000px','700px')" class="dsui-btn-view">生成商品单</a>
                    <?php } ?> -->
                </th>
            </tr>
            <tr>
                <td>
                    <table class="ds-default-table goods ">
                        <tbody>
                            <tr>
                                <th class="align-center">设备编号</th>
                                <th class="align-center">设备名称</th>
                                <th class="align-center">品牌</th>
                                <th class="align-center">工时</th>
                                <th class="align-center">每工时费用</th>
                                <th class="align-center">服务工时费</th>
                                <th class="align-center">操作</th>
                            </tr>
                            {foreach name="$order_info.goods_items" item="goods"}
                            <tr>
                                <td class="w5 align-center">
                                    <p>{$goods.goods_id}</p>
                                </td>
                                <td class="w20 align-center">
                                    <p>{$goods.goods_name}</p>
                                </td>
                                <td class="w20 align-center"><span class="red_common">{$goods.b_name}</span></td>
                                <td class="w20 align-center">
                                    <p id="need_hours" data-value="{$goods.need_hours}">
                                        {$goods.need_hours}</p>
                                </td>
                                <td class="w20 align-center">
                                    <p id="payper_hour" data-value="{$goods.payper_hour}">
                                        {$goods.payper_hour}</p>
                                </td>
                                <td class="w20 align-center">
                                    <p>{$goods.fuwu_hour}</p>
                                </td>
                                <td class="w20 align-center">
                                    <a href="javascript:dsLayerOpen('{:url('Service/setting',['detail_order_id'=>$goods.id])}','设置服务费 {$Think.lang.ds_service_order}-{$order_info.order_sn}')"
                                        class="dsui-btn-add"><i class="iconfont"></i>查看+服务费</a>

                                    <a href="{:url('Service/projec_goods',['detail_order_id'=>$goods.id])}"
                                        class="dsui-btn-add"><i class="iconfont"></i>+附件</a>
                                </td>
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </td>
            </tr>

            {notempty name="order_log"}
            <tr>
                <th>{$Think.lang.order_handle_history}</th>
            </tr>
            {foreach name="order_log" item="val"}
            <tr>
                <td>
                    {$val.log_role} {$val.log_user}&emsp;{$Think.lang.order_show_at}&emsp;{$val.log_time|date="Y-m-d
                    H:i:s",###}&emsp;{$val.log_msg}
                </td>
            </tr>
            {/foreach}
            {/notempty}
            <tr>
                <th>审核是否通过
                </th>
            </tr>
            <form id="store_form" method="post" novalidate="novalidate">
                <input type="hidden" id='is_have_hours' value="{$is_have_hours}">
                <table class="ds-default-table">
                    <!--店主账号-->
                    <tbody>
                        <!--状态-->
                        <input type="hidden" name="order_id" id="s_order_id" value={$order_info.order_id}>
                        <tr class="noborder" style="background: rgb(255, 255, 255);">
                            <td class="w120"><label class="" for="">审核是否通过:</label></td>
                            <td class="vatop rowform onoff">
                                <select name="order_state" id="order_state">
                                    <option value="2">通过</option>
                                    <option value="6">未通过</option>
                                </select>
                            </td>
                            <td class="vatop tips"></td>
                        </tr>
                        <!--关闭原因-->
                        <tr class="noborder" id="tr_store_close_info" style="display: none;">
                            <td class="w120"><label class="" for="">审核失败原因:</label></td>
                            <td class="vatop rowform">
                                <textarea name="examine_failed_reason" rows="6" class="tarea"
                                    id="store_close_info"></textarea>
                            </td>
                            <td class="vatop tips"></td>
                        </tr>
                        <tr class="noborder" style="background: rgb(255, 255, 255);" id="dors">
                            <td class="required">上门费:</td>
                            <td class="vatop rowform"><input type="text" value="0" name="door_fee" id="door_fee"
                                    class="txt">
                            </td>

                            <td class="vatop tips">请输入数字</td>
                        </tr>

                        <tr class="noborder" id="fuwu">
                            <td class="required">服务内容:</td>
                            <td class="vatop rowform"><textarea name="service_content" rows="6" class="tarea"
                                    id="service_content"></textarea></td>
                            <td class="vatop tips"></td>
                        </tr>

                        <tr class="noborder" style="background: rgb(255, 255, 255);" id="beizhu">
                            <td class="required">备注:</td>
                            <td class="vatop rowform"><input type="text" name="manager_remark" class="txt">
                            </td>
                            <td class="vatop tips">请输入备注</td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr class="tfoot">
                            <td colspan="15"><input class="btn" id="clis" type="button" style="line-height: 30px" value="提交"></td>
                        </tr>
                    </tfoot>
                </table>
            </form>
        </tbody>
    </table>
</div>
<script>
    $(document).ready(function () {
        $("#clis").click(function (e) {
            var status = $('#order_state').val();
            var store_close_info = $('#store_close_info').val();
            var door_fee = $('#door_fee').val();
            var service_content = $('#service_content').val();
            var is_have_hours = $('#is_have_hours').val();

             if(status == 2){
                if (is_have_hours == 1) {
                    layer.msg('请设置服务费');
                    return false;
                }
                if (isNaN(door_fee)) {
                    layer.msg('请填写正确的上门费');
                    return false;
                }
             }
            if (status != 6) {
                if (door_fee.replace(/\s+/g, "") == '' || service_content
                    .replace(/\s+/g, "") == '') {
                    layer.msg('请填写正确的服务内容');
                    return false;
                }
            }


            if (status == 6 && store_close_info.replace(/\s+/g, "") == '') {
                layer.msg('请填写审核失败原因');
                return false;
            }

            if (status == 2) {
               
                if (door_fee == 0) {
                    layer.confirm('上门费用为0元确认提交吗？', {
                        title: '温馨提示'
                    }, function (index) {
                        $("form").submit();
                    })
                    return false;
                }
            }
            $("form").submit();
        });
            
    });

    $(function () {
        $('#order_state').change(function () {
            if ($(this).val() == '6') {
                $('#tr_store_close_info').show();
                $('#dors').hide();
                $('#fuwu').hide();
                $('#beizhu').hide();

            } else {
                $('#tr_store_close_info').hide();
                $('#dors').show();
                $('#fuwu').show();
                $('#beizhu').show();
            }
        });
    });
    //生成商品单
    $(document).on('click', '#btn2', function () {
        var order_id = {
            $order_id
        };
        var obj = $(this);
        $.ajax({
            type: 'POST',
            url: "{:url('service/create_goods')}",
            cache: false,
            data: {
                order_id: order_id
            },
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        location.href = data.url;
                        return false;
                    }, 2000);
                } else {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        location.href = data.url;
                        return false;
                    }, 2000);
                }
            }
        });
        return false;
    });
</script>